cmake_minimum_required(VERSION 2.6)
project( warray )

# Check for out-of-source builds
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
get_filename_component(PARENTDIR ${CMAKE_SOURCE_DIR} PATH)
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${PARENTDIR}" insourcesubdir)
if(insource OR insourcesubdir)
	message(FATAL_ERROR "warray requires an out-of-source build")
endif()

# Find Boost
set(Boost_ADDITIONAL_VERSIONS 1.37 1.38)
find_package( Boost 1.37 REQUIRED unit_test_framework )
include_directories( ${Boost_INCLUDE_DIRS} )

include_directories( . )

# Add the warray library
file(GLOB WARRAY_SRCS . warray/*.cpp)
file(GLOB WARRAY_HDRS . warray/*.h)
add_library( warray STATIC ${WARRAY_SRCS} )
target_link_libraries( warray ${ACCELERATE_LIBRARIES} ${MKL_LIBRARIES} )

# Add the warray regression tests
if( NOT Boost_USE_STATIC_LIBS )
	add_definitions( -DBOOST_TEST_DYN_LINK )
endif()
file(GLOB TESTS_WARRAY_SRCS . tests/warray/*.cpp)
add_executable( warray-tests ${TESTS_WARRAY_SRCS} )
target_link_libraries( warray-tests warray ${Boost_LIBRARIES} )
add_test( run-warray-tests ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/warray-tests )	
